<!-- 这是转发pid到topic的组件 -->
<script setup lang="ts">
import {useRouter, useRoute} from 'vue-router'

import {ServerUtils} from '@/serverUtils';

let route = useRoute()
let router = useRouter()
let pid = Number(route.params['pid'])
let to = Number(route.params['to'])

const refresh = async () => {
    // router.replace({path: await findPostUrl(pid)})
    let post = {} as any
    await ServerUtils.getPosts(null, pid, null, [], 1, 0).then(res => {
        console.log(res)
        if (!res?.total) {
            //404
            return
        } else {
            post = res.list[0]
        }
        if (!post.tid) {
            //404
            return
        }
        router.replace({path: `/bbs/forums/topic/${post.tid}/${to}`})
    })
}
refresh()

</script>
